rm(list=ls())

# set the working directory
# setwd("...") 

# install.packages("ordinal")
library(ordinal)
data_elites <- read.csv("ELITES.csv")
data_voters <- read.csv("VOTERS.csv")
missing <- read.csv("MISSINGNESS.csv")

data_elites$Choose_water_project_100 <- data_elites$Choose_water_project * 100
data_elites$Seek_Input <- as.factor(data_elites$Seek_Input)
data_elites$Receive_Input <- as.factor(data_elites$Receive_Input)

data_voters$Choose_water_project_100 <- data_voters$Choose_water_project * 100

data_voters$Region <- relevel(data_voters$Region, ref="Unsko-sanski canton")

############################## MAIN TEXT ##############################
# Table 1. The Effect of Constituency Preferences on Choosing the Water Project
# All (1)
t1 <- t.test(data_elites[data_elites$Women_support_water_project == 0, "Choose_water_project_100"], data_elites[data_elites$Women_support_water_project == 1, "Choose_water_project_100"])
# Men support water project
round(t1$estimate[1], digits=1) # 80.9
# Women support water project
round(t1$estimate[2], digits=1) # 73.1
# Difference
round(t1$estimate[1]-t1$estimate[2], digits=1) # 7.7
# (Standard Error)
round(as.vector(abs(diff(t1$estimate)/t1$statistic)), digits=1) # 2.2
# p-value
t1$p.value # 0.0006078926
# N
dim(data_elites)[1] # 1389

# Women politicians (2)
t2 <- t.test(data_elites[data_elites$Women_support_water_project == 0 & data_elites$Woman_politician == 1, "Choose_water_project_100"], data_elites[data_elites$Women_support_water_project == 1 & data_elites$Woman_politician == 1, "Choose_water_project_100"])
# Men support water project
round(t2$estimate[1], digits=1) # 78.9
# Women support water project
round(t2$estimate[2], digits=1) # 69.9
# Difference
round(t2$estimate[1]-t2$estimate[2], digits=1)# 9.0
# (Standard Error)
round(as.vector(abs(diff(t2$estimate)/t2$statistic)), digits=1) # 4.5
# p-value
t2$p.value # 0.04656948
# N
dim(data_elites[data_elites$Woman_politician == 1,])[1] # 377

# Men politicians (3)
t3 <- t.test(data_elites[data_elites$Women_support_water_project == 0 & data_elites$Woman_politician == 0, "Choose_water_project_100"], data_elites[data_elites$Women_support_water_project == 1 & data_elites$Woman_politician == 0, "Choose_water_project_100"])
# Men support water project
round(t3$estimate[1], digits=1) # 81.6
# Women support water project
round(t3$estimate[2], digits=1) # 74.4
# Difference
round(t3$estimate[1]-t3$estimate[2],digits=1) # 7.2
# (Standard Error)
round(as.vector(abs(diff(t3$estimate)/t3$statistic)), digits=1) # 2.6
# p-value
t3$p.value # 0.005948152
# N
dim(data_elites[data_elites$Woman_politician == 0,])[1] # 1012

# Table 2. Constituent Input and Genders
mod1 <- clm(Seek_Input ~ Women_constituents1, data=data_elites, link = "probit")
summary(mod1)

mod2 <- clm(Seek_Input ~ Women_constituents1 + Woman_politician + Women_constituents1*Woman_politician, data=data_elites, link="probit")
summary(mod2)

mod3 <- clm(Receive_Input ~ Women_constituents2, data=data_elites, link="probit")
summary(mod3)

mod4 <- clm(Receive_Input ~ Women_constituents2 + Woman_politician + Women_constituents2*Woman_politician, data=data_elites, link="probit")
summary(mod4)

# Table 3. Percent of Voters Choosing the Water Project
# All Voters (1)
t1 <- t.test(data_voters[data_voters$Women_support_water_project == 0, "Choose_water_project_100"], data_voters[data_voters$Women_support_water_project == 1, "Choose_water_project_100"])
# Men citizens support water project
round(t1$estimate[1], digits=1) # 58.5
# Women citizens support water project
round(t1$estimate[2], digits=1) # 53.2
# Difference
round(t1$estimate[1]-t1$estimate[2], digits=1) # 5.29948
# (Standard Error)
round(as.vector(abs(diff(t1$estimate)/t1$statistic)), digits=1) # 1.8
# p-value
t1$p.value # 0.003204779
# N
dim(data_voters)[1] # 3049

# Women Voters (2)
t2 <- t.test(data_voters[data_voters$Women_support_water_project == 0 & data_voters$Woman_voter == 1, "Choose_water_project_100"], data_voters[data_voters$Women_support_water_project == 1 & data_voters$Woman_voter == 1, "Choose_water_project_100"])
# Men citizens support water project
round(t2$estimate[1], digits=1) # 63.4
# Women citizens support water project
round(t2$estimate[2], digits=1) # 56.9
# Difference
round(t2$estimate[1]-t2$estimate[2], digits=1) # 6.6
# (Standard Error)
round(as.vector(abs(diff(t2$estimate)/t2$statistic)), digits=1) # 2.4
# p-value
t2$p.value # 0.00630849
# N
dim(data_voters[data_voters$Woman_voter == 1,])[1] # 1659

# Men Voters (2)
t3 <- t.test(data_voters[data_voters$Women_support_water_project == 0 & data_voters$Woman_voter == 0, "Choose_water_project_100"], data_voters[data_voters$Women_support_water_project == 1 & data_voters$Woman_voter == 0, "Choose_water_project_100"])
# Men citizens support water project
round(t3$estimate[1], digits=1) # 52.4
# Women citizens support water project
round(t3$estimate[2], digits=1) # 49.2
# Difference
round(t3$estimate[1]-t3$estimate[2], digits=1) # 3.2
# (Standard Error)
round(as.vector(abs(diff(t3$estimate)/t3$statistic)), digits=1) # 2.7
# p-value
t3$p.value # 0.2334942
# N
dim(data_voters[data_voters$Woman_voter == 0,])[1] # 1390

############################## ONLINE APPENDIX ##############################
missing$Urbanization <- (missing$Urbanization)/10
missing$GDP_per_capita <- (missing$GDP_per_capita)/10000
missing$Average_wage <- (missing$Average_wage)/100
missing$Seat_fractionalization <- (missing$Seat_fractionalization)*100
missing$Vote_fractionalization <- (missing$Vote_fractionalization)*100

data_elites$Urbanization <- (data_elites$Urbanization)/10
data_elites$GDP_per_capita <- (data_elites$GDP_per_capita)/10000
data_elites$Average_wage <- (data_elites$Average_wage)/100
data_elites$Seat_fractionalization <- (data_elites$Seat_fractionalization)*100
data_elites$Vote_fractionalization <- (data_elites$Vote_fractionalization)*100

data_voters$Urbanization <- (data_voters$Urbanization)/10
data_voters$GDP_per_capita <- (data_voters$GDP_per_capita)/10000
data_voters$Average_wage <- (data_voters$Average_wage)/100
data_voters$Seat_fractionalization <- (data_voters$Seat_fractionalization)*100
data_voters$Vote_fractionalization <- (data_voters$Vote_fractionalization)*100

# Table OA.1.1. Determinants of Non-Response across Municipalities
summary(mod1 <- lm(Participation_rate ~ Log_Casualties + Urbanization + GDP_per_capita + Average_wage + Agricultural_activity + Fertility_rate + Female_employment + Female_participation + Female_literacy + Employment_difference + Participation_difference + Literacy_difference + Seat_fractionalization + Vote_fractionalization + SDP_seat_share + SDP_vote_share + Womens_vote_share, data=missing))
nobs(mod1)

summary(mod2 <- lm(Participation_rate ~ Casualty_rate + Urbanization + GDP_per_capita + Average_wage + Agricultural_activity + Fertility_rate + Female_employment + Female_participation + Female_literacy + Employment_difference + Participation_difference + Literacy_difference + Seat_fractionalization + Vote_fractionalization + SDP_seat_share + SDP_vote_share + Womens_vote_share, data=missing))
nobs(mod2)

summary(mod3 <- lm(Participation_rate ~ Log_Fatalities + Urbanization + GDP_per_capita + Average_wage + Agricultural_activity + Fertility_rate + Female_employment + Female_participation + Female_literacy + Employment_difference + Participation_difference + Literacy_difference + Seat_fractionalization + Vote_fractionalization + SDP_seat_share + SDP_vote_share + Womens_vote_share, data=missing))
nobs(mod3)

summary(mod4 <- lm(Participation_rate ~ Fatality_rate + Urbanization + GDP_per_capita + Average_wage + Agricultural_activity + Fertility_rate + Female_employment + Female_participation + Female_literacy + Employment_difference + Participation_difference + Literacy_difference + Seat_fractionalization + Vote_fractionalization + SDP_seat_share + SDP_vote_share + Womens_vote_share, data=missing))
nobs(mod4)

# Table OA.1.2. Determinants of Non-Response across Municipalities (Continued)
summary(mod1 <- lm(Participation_rate ~ Camps_committed + Urbanization + GDP_per_capita + Average_wage + Agricultural_activity + Fertility_rate + Female_employment + Female_participation + Female_literacy + Employment_difference + Participation_difference + Literacy_difference + Seat_fractionalization + Vote_fractionalization + SDP_seat_share + SDP_vote_share + Womens_vote_share, data=missing))
nobs(mod1)

summary(mod2 <- lm(Participation_rate ~ Camps_common + Urbanization + GDP_per_capita + Average_wage + Agricultural_activity + Fertility_rate + Female_employment + Female_participation + Female_literacy + Employment_difference + Participation_difference + Literacy_difference + Seat_fractionalization + Vote_fractionalization + SDP_seat_share + SDP_vote_share + Womens_vote_share, data=missing))
nobs(mod2)

summary(mod3 <- lm(Participation_rate ~ Camps_primary + Urbanization + GDP_per_capita + Average_wage + Agricultural_activity + Fertility_rate + Female_employment + Female_participation + Female_literacy + Employment_difference + Participation_difference + Literacy_difference + Seat_fractionalization + Vote_fractionalization + SDP_seat_share + SDP_vote_share + Womens_vote_share, data=missing))
nobs(mod3)

# Table OA2.1. Balance Check, Sample of Politicians
summary(mod1 <- glm(Women_support_water_project ~ Woman_politician + Bosniak_politician + Croat_politician + Serb_politician + Elected_official + Years_in_office + Republika_Srpska, data=data_elites, family = binomial(link="probit")))
nobs(mod1)

# Table OA2.2. Balance Check, Sample of Citizens
summary(mod1 <- glm(Women_support_water_project ~ Woman_voter + Bosniak_voter + Croat_voter + Serb_voter + Age + Education_secondary + Education_university + Employed + Married + Urban + Size_of_household + Region, data=data_voters, family = binomial(link="probit")))
nobs(mod1)
 
# Table OA.3.1. The Effect of Constituency Preferences on Choosing the Water Project across Personal Violence Exposure
summary(mod1 <- glm(Choose_water_project ~ Women_support_water_project + War_participation + Women_support_water_project*War_participation, data=data_elites, family = binomial(link="probit")))
nobs(mod1)
summary(mod2 <- glm(Choose_water_project ~ Women_support_water_project + Violence_exposure + Women_support_water_project*Violence_exposure, data=data_elites, family = binomial(link="probit")))
nobs(mod2)
summary(mod3 <- glm(Choose_water_project ~ Women_support_water_project + Sexual_violence_exposure + Women_support_water_project*Sexual_violence_exposure, data=data_elites, family = binomial(link="probit")))
nobs(mod3)

# Table OA.3.2. The Effect of Constituency Preferences on Choosing the Water Project across Violence Severity
summary(mod1 <- glm(Choose_water_project ~ Women_support_water_project + Log_Casualties + Women_support_water_project*Log_Casualties, data=data_elites, family = binomial(link="probit")))
nobs(mod1)
summary(mod2 <- glm(Choose_water_project ~ Women_support_water_project + Casualty_rate + Women_support_water_project*Casualty_rate, data=data_elites, family = binomial(link="probit")))
nobs(mod2)
summary(mod3 <- glm(Choose_water_project ~ Women_support_water_project + Log_Fatalities + Women_support_water_project*Log_Fatalities, data=data_elites, family = binomial(link="probit")))
nobs(mod3)
summary(mod4 <- glm(Choose_water_project ~ Women_support_water_project + Fatality_rate + Women_support_water_project*Fatality_rate, data=data_elites, family = binomial(link="probit")))
nobs(mod4)

# Table OA.3.3. The Effect of Constituency Preferences on Choosing the Water Project across Sexual Violence Severity
summary(mod1 <- glm(Choose_water_project ~ Women_support_water_project + Camps_committed + Women_support_water_project*Camps_committed, data=data_elites, family = binomial(link="probit")))
nobs(mod1)
summary(mod2 <- glm(Choose_water_project ~ Women_support_water_project + Camps_common + Women_support_water_project*Camps_common, data=data_elites, family = binomial(link="probit")))
nobs(mod2)
summary(mod3 <- glm(Choose_water_project ~ Women_support_water_project + Camps_primary + Women_support_water_project*Camps_primary, data=data_elites, family = binomial(link="probit")))
nobs(mod3)

# Table OA.3.4. Voters Choosing the Water Project across Violence Severity
summary(mod1 <- glm(Choose_water_project ~ Women_support_water_project + Log_Casualties + Women_support_water_project*Log_Casualties, data=data_voters, family = binomial(link="probit")))
nobs(mod1)
summary(mod2 <- glm(Choose_water_project ~ Women_support_water_project + Casualty_rate + Women_support_water_project*Casualty_rate, data=data_voters, family = binomial(link="probit")))
nobs(mod2)
summary(mod3 <- glm(Choose_water_project ~ Women_support_water_project + Log_Fatalities + Women_support_water_project*Log_Fatalities, data=data_voters, family = binomial(link="probit")))
nobs(mod3)
summary(mod4 <- glm(Choose_water_project ~ Women_support_water_project + Fatality_rate + Women_support_water_project*Fatality_rate, data=data_voters, family = binomial(link="probit")))
nobs(mod4)

# Table OA.3.5. Voters Choosing the Water Project across Sexual Violence Severity
summary(mod1 <- glm(Choose_water_project ~ Women_support_water_project + Camps_committed + Women_support_water_project*Camps_committed, data=data_voters, family = binomial(link="probit")))
nobs(mod1)
summary(mod2 <- glm(Choose_water_project ~ Women_support_water_project + Camps_common + Women_support_water_project*Camps_common, data=data_voters, family = binomial(link="probit")))
nobs(mod2)
summary(mod3 <- glm(Choose_water_project ~ Women_support_water_project + Camps_primary + Women_support_water_project*Camps_primary, data=data_voters, family = binomial(link="probit")))
nobs(mod3)

# Table OA.3.6. The Effect of Constituency Preferences on Choosing the Water Project across Politician Ethnicity
summary(mod1 <- glm(Choose_water_project ~ Women_support_water_project + Bosniak_politician + Women_support_water_project*Bosniak_politician, data=data_elites, family = binomial(link="probit")))
nobs(mod1)
summary(mod2 <- glm(Choose_water_project ~ Women_support_water_project + Croat_politician + Women_support_water_project*Croat_politician, data=data_elites, family = binomial(link="probit")))
nobs(mod2)
summary(mod3 <- glm(Choose_water_project ~ Women_support_water_project + Serb_politician + Women_support_water_project*Serb_politician, data=data_elites, family = binomial(link="probit")))
nobs(mod3)

# Table OA.3.7. Voters Choosing the Water Project across Ethnicity 
summary(mod1 <- glm(Choose_water_project ~ Women_support_water_project + Bosniak_voter + Women_support_water_project*Bosniak_voter, data=data_voters, family = binomial(link="probit")))
nobs(mod1)
summary(mod2 <- glm(Choose_water_project ~ Women_support_water_project + Croat_voter + Women_support_water_project*Croat_voter, data=data_voters, family = binomial(link="probit")))
nobs(mod2)
summary(mod3 <- glm(Choose_water_project ~ Women_support_water_project + Serb_voter + Women_support_water_project*Serb_voter, data=data_voters, family = binomial(link="probit")))
nobs(mod3)

# Table OA.3.8. The Effect of Constituency Preferences on Choosing the Water Project across Electoral Conditions
summary(mod1 <- glm(Choose_water_project ~ Women_support_water_project + Seat_fractionalization + Women_support_water_project*Seat_fractionalization, data=data_elites, family = binomial(link="probit")))
nobs(mod1)
summary(mod2 <- glm(Choose_water_project ~ Women_support_water_project + Vote_fractionalization + Women_support_water_project*Vote_fractionalization, data=data_elites, family = binomial(link="probit")))
nobs(mod2)
summary(mod3 <- glm(Choose_water_project ~ Women_support_water_project + SDP_seat_share + Women_support_water_project*SDP_seat_share, data=data_elites, family = binomial(link="probit")))
nobs(mod3)
summary(mod4 <- glm(Choose_water_project ~ Women_support_water_project + SDP_vote_share + Women_support_water_project*SDP_vote_share, data=data_elites, family = binomial(link="probit")))
nobs(mod4)
summary(mod5 <- glm(Choose_water_project ~ Women_support_water_project + Womens_vote_share + Women_support_water_project*Womens_vote_share, data=data_elites, family = binomial(link="probit")))
nobs(mod5)

# Table OA.3.9. The Effect of Constituency Preferences on Choosing the Water Project across Levels of Development
summary(mod1 <- glm(Choose_water_project ~ Women_support_water_project + Urbanization + Women_support_water_project*Urbanization, data=data_elites, family = binomial(link="probit")))
nobs(mod1)
summary(mod2 <- glm(Choose_water_project ~ Women_support_water_project + GDP_per_capita + Women_support_water_project*GDP_per_capita, data=data_elites, family = binomial(link="probit")))
nobs(mod2)
summary(mod3 <- glm(Choose_water_project ~ Women_support_water_project + Average_wage + Women_support_water_project*Average_wage, data=data_elites, family = binomial(link="probit")))
nobs(mod3)
summary(mod4 <- glm(Choose_water_project ~ Women_support_water_project + Agricultural_activity + Women_support_water_project*Agricultural_activity, data=data_elites, family = binomial(link="probit")))
nobs(mod4)
summary(mod5 <- glm(Choose_water_project ~ Women_support_water_project + Fertility_rate + Women_support_water_project*Fertility_rate, data=data_elites, family = binomial(link="probit")))
nobs(mod5)

# Table OA.3.10. The Effect of Constituency Preferences on Choosing the Water Project across Women’s Status and Gender Disparities
summary(mod1 <- glm(Choose_water_project ~ Women_support_water_project + Female_employment  + Women_support_water_project*Female_employment, data=data_elites, family = binomial(link="probit")))
nobs(mod1)
summary(mod2 <- glm(Choose_water_project ~ Women_support_water_project + Female_participation  + Women_support_water_project*Female_participation, data=data_elites, family = binomial(link="probit")))
nobs(mod2)
summary(mod3 <- glm(Choose_water_project ~ Women_support_water_project + Female_literacy + Women_support_water_project*Female_literacy, data=data_elites, family = binomial(link="probit")))
nobs(mod3)
summary(mod4 <- glm(Choose_water_project ~ Women_support_water_project + Employment_difference + Women_support_water_project*Employment_difference, data=data_elites, family = binomial(link="probit")))
nobs(mod4)
summary(mod5 <- glm(Choose_water_project ~ Women_support_water_project + Participation_difference + Women_support_water_project*Participation_difference, data=data_elites, family = binomial(link="probit")))
nobs(mod5)
summary(mod6 <- glm(Choose_water_project ~ Women_support_water_project + Literacy_difference + Women_support_water_project*Literacy_difference, data=data_elites, family = binomial(link="probit")))
nobs(mod6)

# Table OA.3.11. Voters Choosing the Water Project across Levels of Development 
summary(mod1 <- glm(Choose_water_project ~ Women_support_water_project + Urbanization + Women_support_water_project*Urbanization, data=data_voters, family = binomial(link="probit")))
nobs(mod1)
summary(mod2 <- glm(Choose_water_project ~ Women_support_water_project + GDP_per_capita + Women_support_water_project*GDP_per_capita, data=data_voters, family = binomial(link="probit")))
nobs(mod2)
summary(mod3 <- glm(Choose_water_project ~ Women_support_water_project + Average_wage + Women_support_water_project*Average_wage, data=data_voters, family = binomial(link="probit")))
nobs(mod3)
summary(mod4 <- glm(Choose_water_project ~ Women_support_water_project + Agricultural_activity + Women_support_water_project*Agricultural_activity, data=data_voters, family = binomial(link="probit")))
nobs(mod4)
summary(mod5 <- glm(Choose_water_project ~ Women_support_water_project + Fertility_rate + Women_support_water_project*Fertility_rate, data=data_voters, family = binomial(link="probit")))
nobs(mod5)

# Table OA.3.12. Voters Choosing the Water Project across Women’s Status and Gender Disparities
summary(mod1 <- glm(Choose_water_project ~ Women_support_water_project + Female_employment  + Women_support_water_project*Female_employment, data=data_voters, family = binomial(link="probit")))
nobs(mod1)
summary(mod2 <- glm(Choose_water_project ~ Women_support_water_project + Female_participation  + Women_support_water_project*Female_participation, data=data_voters, family = binomial(link="probit")))
nobs(mod2)
summary(mod3 <- glm(Choose_water_project ~ Women_support_water_project + Female_literacy + Women_support_water_project*Female_literacy, data=data_voters, family = binomial(link="probit")))
nobs(mod3)
summary(mod4 <- glm(Choose_water_project ~ Women_support_water_project + Employment_difference + Women_support_water_project*Employment_difference, data=data_voters, family = binomial(link="probit")))
nobs(mod4)
summary(mod5 <- glm(Choose_water_project ~ Women_support_water_project + Participation_difference + Women_support_water_project*Participation_difference, data=data_voters, family = binomial(link="probit")))
nobs(mod5)
summary(mod6 <- glm(Choose_water_project ~ Women_support_water_project + Literacy_difference + Women_support_water_project*Literacy_difference, data=data_voters, family = binomial(link="probit")))
nobs(mod6)


